package com.dudu.controller;

import com.dudu.model.OrgInfo;
import com.dudu.model.User;
import com.dudu.model.UserType;
import com.dudu.model.dto.UserDto;
import com.dudu.model.vo.AppRequest;
import com.dudu.model.vo.CommonRequestVO;
import com.dudu.model.vo.LoginVO;
import com.dudu.model.vo.RegisterVO;
import com.dudu.model.vo.SmsCodeVO;
import com.dudu.service.OrgService;
import com.dudu.service.UserService;
import com.dudu.util.ControllerUtils;
import com.dudu.util.ResponseBuilder;
import com.dudu.util.WebResponse;

import com.dudu.util.WebResponseHelper;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * Created by dudu on 2016/12/4.
 */
@Controller
@RequestMapping("/v1/user")
public class UserController {

    @Resource
    private UserService userService;
    

    @RequestMapping("/reg.json")
    @ResponseBody
    public WebResponse<?> reg(@RequestBody AppRequest<RegisterVO> params) {
        UserDto userDto = userService.reg(params.getData());
        return ResponseBuilder.create().setData(userDto).build();
    }

    @RequestMapping("/login.json")
    @ResponseBody
    public WebResponse<?> login(@RequestBody AppRequest<LoginVO> params) {

        UserDto userDto = userService.login(params.getData());
        return ResponseBuilder.create().setData(userDto).build();
    }




    


}
